#include <stdio.h>
#include<sys/types.h>
#include<unistd.h>

int main()
{
  int a = 520;

  pid_t ret = fork();
  if (ret == 0)
  {
    while (1)
    {
      printf("I am child, my PID is %d,子进程中a的值是 %d 地址是 %p\n", getpid(), a, &a);
      sleep(2);
    }
  }
  else if (ret > 0)
  {
    while (1)
    {
      printf("I am father, my PID is %d,父进程中a的值是 %d 地址是 %p\n", getpid(), a, &a);
      sleep(2);
    }
  }
  else{
    printf("创建子进程失败\n");
  }
  return 0;
}
